center css

65

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}
IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
 ...
<IMG class="displayed" src="..." alt="...">
element {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
}
div.container4 {
    height: 10em;
    position: relative }
div.container4 p {
    margin: 0;
    background: yellow;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%) }
element {
  position: absolute;
  top: 0;
  bottom: 0;
  margin: auto 0;
}

Comments

Submit
0 Comments